package cn.edu.sjtu.se.dslab.dao.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Repository;

import cn.edu.sjtu.se.dslab.action.bean.PageBean;
import cn.edu.sjtu.se.dslab.auth.Group;
import cn.edu.sjtu.se.dslab.dao.IBaseDao;
import cn.edu.sjtu.se.dslab.dao.IGroupDao;
import cn.edu.sjtu.se.dslab.exception.DBException;
@Repository("groupDao")
public class GroupDaoImpl implements IGroupDao {

	/**
	 * Properties
	 */
	@Resource(name = "baseDao")
	private IBaseDao<Group> baseDao;
	
	@Override
	public void save(Group group) {
		// TODO Auto-generated method stub
		baseDao.save(group);
	}

	@Override
	public void update(Group group) {
		// TODO Auto-generated method stub
		baseDao.update(group);
	}

	@Override
	public long rowCount() {
		// TODO Auto-generated method stub
		short status = -1;
		return baseDao.countAll("Group", status, null);
	}

	@Override
	public Group queryById(long id) {
		// TODO Auto-generated method stub
		return baseDao.queryById(Group.class, id);
	}

	@Override
	public void delete(Group group) {
		// TODO Auto-generated method stub
		baseDao.delete(group);
	}

	@Override
	public void deleteById(long id) {
		// TODO Auto-generated method stub
		baseDao.delById(Group.class, id);
	}

	@Override
	public List<Group> queryAll() {
		// TODO Auto-generated method stub
		return baseDao.queryList("Group");
	}

	@Override
	public PageBean<Group> queryByPage(int pageNum, int pageSize) throws DBException{
		// TODO Auto-generated method stub
		PageBean<Group> bean = baseDao.queryByHqlForPage(pageNum, pageSize, "Group");
		return bean;
	}

}
